package com.gitee.cui.netty.encoder;

import com.gitee.cui.util.Logger;
import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.MessageToByteEncoder;

/**
 * 整型转换为ByteBuf编码器
 * @author cuiqingqiang
 * @version 1.0
 * @date 2021/10/25 10:10
 **/
public class Integer2ByteEncoder extends MessageToByteEncoder<Integer> {
    @Override
    protected void encode(ChannelHandlerContext ctx, Integer msg, ByteBuf out) throws Exception {
        out.writeInt(msg);
        Logger.info("encoder Integer:" + msg);
    }
}
